﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace PHPTibia
{
    public partial class LoginScreen : Form
    {
        public LoginScreen()
        {
            InitializeComponent();
            this.BackgroundImage = Image.FromFile("./GFX/BG/screen_login.png");
        }

        private void button1_Click(object sender, EventArgs e)
        {
            pictureBox1.Visible = true;
            Image Grass = Image.FromFile("./GFX/Terrain/Grass/grass.png");
            Image Ground = Image.FromFile("./GFX/Terrain/Ground/ground.png");
            Image Water = Image.FromFile("./GFX/Terrain/Water/water.png");
            Image CliffWall = Image.FromFile("./GFX/Terrain/Cliff/dirt-cliff.png");
            Image CliffGround = Image.FromFile("./GFX/Terrain/Cliff/dirt-ground.png");
            IsometricGridRenderer igr = new IsometricGridRenderer(pictureBox1.Width, pictureBox1.Height);
            pictureBox1.Image = igr.Output;
            IsometricGridTile igt;
            IsometricGridTile wat = new IsometricGridTile();
            wat.Texture = Water;
            wat.Type = IsometricGridTileType.Textured;
            igr.Clear(wat);
            bool test = false, test2 = false, rand = true;
            Random ran = new Random();
            #region Test1
            if (test)
            {
                var col = 0;
                for (int x = 0; x < igr.GetTiles().Width; x++)
                {
                    for (int y = 0; y < igr.GetTiles().Height; y++)
                    {
                        igt = new IsometricGridTile();
                        Color c = Color.White;
                        switch (col)
                        {
                            case 0:
                                col++;
                                if (rand) col = ran.Next(0, 5);
                                c = Color.Black;
                                break;
                            case 1:
                                col++;
                                if (rand) col = ran.Next(0, 5);
                                c = Color.White;
                                break;
                            case 2:
                                col++;
                                if (rand) col = ran.Next(0, 5);
                                c = Color.Red;
                                break;
                            case 3:
                                col++;
                                if (rand) col = ran.Next(0, 5);
                                c = Color.Green;
                                break;
                            case 4:
                                col++;
                                if (rand) col = ran.Next(0, 5);
                                c = Color.Blue;
                                break;
                            case 5:
                                col = 0;
                                if (rand) col = ran.Next(0, 5);
                                c = Color.Gold;
                                break;
                        }
                        igt.Level = (short)col;
                        igt.Color = c;
                        igr.SetTile(x, y, igt);
                    }
                }
            } 
            #endregion
            #region Test2
            if (test2)
            {
                var col = 0;
                for (int x = 0; x < igr.GetTiles().Width; x++)
                {
                    for (int y = 0; y < igr.GetTiles().Height; y++)
                    {
                        igt = new IsometricGridTile();
                        igt.Type = IsometricGridTileType.Textured;
                        igt.IsReflectible = true;
                        Image t = Water;
                        switch (col)
                        {
                            case 0:
                                col++;
                                if (rand) col = ran.Next(0, 5);
                                t = Ground;
                                break;
                            case 1:
                                col++;
                                if (rand) col = ran.Next(0, 5);
                                t = Grass;
                                break;
                            case 2:
                                col++;
                                if (rand) col = ran.Next(0, 5);
                                t = Grass;
                                break;
                            case 3:
                                col++;
                                if (rand) col = ran.Next(0, 5);
                                t = Ground;
                                break;
                            case 4:
                                col++;
                                if (rand) col = ran.Next(0, 5);
                                t = CliffWall;
                                break;
                            case 5:
                                col = 0;
                                if (rand) col = ran.Next(0, 5);
                                t = Water;
                                break;
                        }
                        igt.Level = (short)col;
                        igt.Texture = t;
                        if (col == 5)
                        {
                            igt.ReflectX = 0;
                            igt.ReflectY = -1;
                            igt.Reflectivity = 100;
                            igt.IsReflectible = false;
                            igt.Level = -1;
                        }
                        igr.SetTile(x, y, igt);
                    }
                }
            }
            #endregion
            if (!test && !test2)
            {
                
            }
        }
    }
}
